from django.contrib import admin
from .models import *


class DishesInline(admin.StackedInline):
    # 内嵌模型
    model = Dishes


@admin.register(DishClassify)
class DishClassifyAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "classify", "en_classify", "classify_img", "classify_desc"]
    # 搜索框
    search_fields = ["classify", "en_classify"]
    # 过滤器
    list_filter = ["is_delete"]
    # 内嵌菜品dishes表
    inlines = [DishesInline]



@admin.register(Dishes)
class DishesAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "dish_name", "dish_type","dish_price", "dish_img", "dish_short","dish_desc","dish_praise","dish_response"]
    # 过滤器
    list_filter = ["dish_type","is_delete"]
    # 搜索框
    search_fields = ["dish_name"]



@admin.register(DishResponse)
class DishResponseAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "user_name", "response", "response_dish"]

    # 搜索框
    search_fields = ["user_name","response_dish"]


